<?php
/**
 * 系统设置
 *
 * @copyright  Copyright (c) 2015-2025 NcPHP Inc. (http://www.ncphp.com)
 * @license    http://www.ncphp.com
 * @link       http://www.ncphp.com
 * @since      File available since Release v1.1
 */
defined('InNcPHP') or exit('Access Invalid!');
class settingModel extends Model{

	public function __construct(){
		parent::__construct('setting');
	}

	// 列表
	public function getListSetting(){
		$result = $this->select();
		if (is_array($result)){
			$list_setting = array();
			foreach ($result as $k => $v){
				$list_setting[$v['name']] = $v['value'];
			}
		}
		return $list_setting;
	}

	// 信息
	public function getRowSetting($condition){
		return $this->whre($condition)->find();
	}

	// 更新
	public function updateSetting($param){
		if(empty($param)) return false;

		if (is_array($param)){
			foreach ($param as $k => $v){
				$tmp = array();
				$tmp['value'] = $v;
				$where = " name = '". $k ."'";
				$result = $this->where($where)->update($tmp);
				if ($result !== true){
					return $result;
				}
			}
			@unlink(BASE_DATA_PATH.DS.'cache'.DS.'setting.php');
			H('setting', true);
			return true;
		}else{
			return false;
		}
	}
}